import {
  queryTempFunctionCode
} from '../../../utils/login'
import {saveMatter} from '../../../utils/my'

Page({

  /**
   * 页面的初始数据
   */
  data: {
    menuInfo: {},
    str:[
      // {id:'1',name:'养老保险',src:'/images/more/shbx1.png',code:''},
      // {id:'2',name:'失业保险',src:'/images/more/shbx6.png',code:''},
      // {id:'3',name:'工伤保险',src:'/images/more/shbx3.png',code:''},
      // {id:'4',name:'2022年企业退休人员养老金调整情况说明',src:'/images/more/ldgx3.png',code:''},
      {id:'5',name:'灵活就业人员停保登记',src:'/images/new/lhjerytb.png',code:'SHBX_0001',icon:'shbx1'},
      {id:'6',name:'个人权益单',src:'/images/new/grqyd.png',code:'SHBX_0024',icon:'shbx8'},
      {id:'7',name:'失业待遇发放记录查询',src:'/images/more/sydyffjlcx.png',code:'SHBX_0029',icon:'shbx5'},
      {id:'8',name:'养老待遇发放查询',src:'/images/more/yljdyffjl.png',code:'SHBX_0035',icon:'shbx12'},
      {id:'9',name:'城乡居民参保信息查询',src:'/images/new/shbx1.png',code:'SHBX_0040',icon:'shbx6'},
      {id:'10',name:'城乡居民待遇标准信息查询',src:'/images/new/shbx2.png',code:'SHBX_0041',icon:'shbx10'},
      {id:'10',name:'城乡居民待遇人员发放信息查询',src:'/images/new/shbx3.png',code:'SHBX_0042',icon:'shbx17'},
      {id:'11',name:'城乡居民缴费记录查询',src:'/images/new/shbx4.png',code:'SHBX_0043',icon:'shbx16'},
      {id:'12',name:'企业退休人员体检预约',src:'/images/new/shbx4.png',code:'SHBX_0010',icon:'shbx11'},
      {id:'13',name:'灵活就业人员就业和社会保险登记',src:'/images/new/shbx4.png',code:'SHBX_0002',icon:'shbx9'},
      {id:'14',name:'养老金调整情况查询',src:'/images/new/shbx4.png',code:'SHBX_0031',icon:'shbx15'},
      {id:'15',name:'待遇资格认证',src:'/images/new/shbx4.png',code:'SHBX_0026',icon:'shbx13'},
    ]
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {

  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady() {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow() {
    //设置头部字体与导航栏对齐
    const top= getApp()
    this.setData({
      menuInfo:top.geibartop.menuInfo
    })
  },
  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom() {

  },
  //跳转页面
  jumpPage(e) {
    const code = e.currentTarget.dataset.code;
    const name = e.currentTarget.dataset.name;
    if(code){
      queryTempFunctionCode(code).then(res => {
        saveMatter(name) //保存事项
        wx.navigateTo({
          url: '/pages/web_h5/web_h5?url=' + encodeURIComponent(res.data)
        })
      })
    }else{
      wx.showToast({
        title: '功能代码错误！',
        icon: 'error',
        duration: 2000
      })
    }
    // console.log( e.currentTarget.dataset);
    // wx.navigateTo({
    //   url: e.currentTarget.dataset.url
    // })
  },
  toTxDaCx(){
    if (wx.getStorageSync('userInfo')) {
      wx.navigateTo({
        url: '/pages/SocialInsurance/txdacx/txdacx'
      })
    } else {
      this.sctt()
    }
  },
  //返回上一级
  backPage(){
    wx.navigateBack({
      delta: 1
    });    
  },
})